package org.game.module.event.listener;

import org.constant.EventType;
import org.game.db.bean.Player;
import org.game.plugin.event.GameEvent;
import org.game.plugin.event.GameEventListener;
import org.game.plugin.event.GameEventStack;
import org.game.plugin.event.GameEventType;

import com.sojoys.artifact.tools.ToolMap;

/**
 * 充值事件监听器
 * 
 * @author SandKing
 *
 */
@GameEventType(EventType.RECHARGE)
public class RechargeEventListener implements GameEventListener {

	@Override
	public void onEvent(GameEvent event) {
		GameEventStack eventStack = event.peek();
		switch (eventStack.getConditionType()) {
		// 总累计充值
		case 1: {
			int num = ToolMap.getInt("num", event.getIn());
			eventStack.changeProgress(num);
		}
			break;
		// 事件时效累计充值
		case 2: {
			int num = ToolMap.getInt("num", event.getIn());
			eventStack.changeProgress(num);
			break;
		}
		// 单笔充值
		case 3: {
			int num = ToolMap.getInt("num", event.getIn());
			int _num = ToolMap.getInt("num", eventStack.getParams());
			if (num >= _num) {
				eventStack.changeProgress(num);				
			}
			break;
		}
		// 定额充值
		case 4: {
			int num = ToolMap.getInt("num", event.getIn());
			int _num = ToolMap.getInt("num", eventStack.getParams());
			if (num == _num) {
				eventStack.changeProgress(num);
			}
			break;
		}
		default:
			break;
		}
	}

	@Override
	public void initEventCondition(Player player, GameEventStack eventStack) {
		
	}


}
